home *** CD-ROM | disk | FTP | other *** search
/ Aminet 19 / Aminet 19 (1997)(GTI - Schatztruhe)[!][Jun 1997].iso / Aminet / misc / sci / log_lib.lha / ChipMunk / log / lib / preamble.ps < prev    next >
Text File  |  1996-05-18  |  6KB  |  200 lines

  1. %!PS-Adobe-2.0
  2. % Caged_date='r% Last change: $x by $u'
  3. % Last change: Feb 1, 1989 3:16:38 pm by calvin
  4. /UntilState save def
  5. 180 dict begin
  6. /UNTILFINISH { end UntilState restore } def
  7. %%BoundingBox: 20 20 576 756
  8. % $ Include /lib/laserwriter/texstuff.ps
  9. %  PS-in-TeX macros
  10.  
  11. % Determine whether or not we are being called from TeX.  Currently, this
  12. % relies on GPOSX being defined or not.
  13. %
  14. %  Is-TeX <boolean>
  15. %
  16. /GPOSX where /Is-TeX exch def Is-TeX {pop} if % Define Is-TeX and eat "dict"
  17.  
  18. % Try to define the current TeX-MBB.  If not Is-TeX then use the user-supplied
  19. % TeX-MBB or the whole page if TeX-MBB can not be found.
  20. %
  21. %  TeX-MBB <[mbb in TeX space]>
  22. %
  23. Is-TeX
  24.    {/TeX-MBB [GPOSX GPOSY currentpoint] def}
  25.    {/TeX-MBB where {pop} {/TeX-MBB [20 20 576 756] def} ifelse}
  26. ifelse
  27.  
  28. %
  29. %  Define a couple of macros that do stuff if you are in TeX or not.
  30. %
  31. %  <procedure> In-Tex
  32. %  <procedure> Not-In-Tex
  33. %
  34. /In-TeX {Is-TeX exch if} def
  35. /Not-In-TeX {Is-TeX not exch if} def
  36.  
  37. %
  38. %  Set up square scaling given an MBB
  39. %
  40. %  <[user-mbb]> TeX-do-square-scale
  41. %
  42. /TeX-do-square-scale {
  43.    % get User mbb
  44.       aload pop
  45.       /U-top   exch def
  46.       /U-right exch def
  47.       /U-bot   exch def
  48.       /U-left  exch def
  49.    % sort MBB
  50.       U-top U-bot lt    {U-top U-bot /U-top exch def /U-bot exch def} if
  51.       U-right U-left lt {U-right U-left /U-right exch def /U-left exch def} if
  52.    /U-height U-top U-bot sub def
  53.    /U-width  U-right U-left sub def
  54.    % get TeX MBB
  55.       TeX-MBB aload pop
  56.       /T-top   exch def
  57.       /T-right exch def
  58.       /T-bot   exch def
  59.       /T-left  exch def
  60.    % sort MBB
  61.       T-top T-bot lt    {T-top T-bot /T-top exch def /T-bot exch def} if
  62.       T-right T-left lt {T-right T-left /T-right exch def /T-left exch def} if
  63.    /T-height T-top T-bot sub def
  64.    /T-width  T-right T-left sub def
  65.    % Compute scaling in X and Y
  66.       /S-x T-width  U-width  div def
  67.       /S-y T-height U-height div def
  68.    % Make scales equal and center Tex-Mbb
  69.    % extra height=(T-height - S-x * U-height)
  70.    % Then divide by 2 and add to bottom (similar for extrawidth) }
  71.       S-x S-y gt
  72.       { /S-x S-y def 
  73.         T-width S-x U-width mul sub 2 div T-left add /T-left exch def }
  74.       { /S-y S-x def
  75.         T-height S-x U-height mul sub 2 div T-bot add /T-bot exch def }
  76.    ifelse
  77.    % Compute translation
  78.    T-left T-bot translate
  79.    S-x S-y scale
  80.    % Compute translation
  81.    U-left neg U-bot neg translate
  82. } def
  83.  
  84. %
  85. %  Set up non-square scaling given an MBB
  86. %
  87. %  <[user-mbb]> TeX-do-scale
  88. %
  89. /TeX-do-scale {
  90.    aload pop % get User mbb
  91.    /U-top   exch def
  92.    /U-right exch def
  93.    /U-bot   exch def
  94.    /U-left  exch def
  95.    /U-height U-top U-bot sub def
  96.    /U-width  U-right U-left sub def
  97.    TeX-MBB aload pop % get TeX MBB
  98.    /T-top   exch def
  99.    /T-right exch def
  100.    /T-bot   exch def
  101.    /T-left  exch def
  102.    /T-height T-top T-bot sub def
  103.    /T-width  T-right T-left sub def
  104.    % Compute scaling in X and Y
  105.    /S-x T-width  U-width  div def
  106.    /S-y T-height U-height div def
  107.    % Compute translation
  108.    T-left T-bot translate
  109.    S-x S-y scale
  110.    % Compute translation
  111.    U-left neg U-bot neg translate
  112. } def
  113.  
  114. %
  115. % Draw a box around an mbb-array
  116. %
  117. % <[mbb]> TeX-mbb-box
  118. %
  119. /TeX-mbb-box {
  120.    aload pop
  121.    /B-ury exch def
  122.    /B-urx exch def
  123.    /B-lly exch def
  124.    /B-llx exch def
  125.    newpath B-llx B-lly moveto B-llx B-ury lineto B-urx B-ury
  126.    lineto B-urx B-lly lineto closepath stroke
  127. } def
  128.  
  129.  
  130.  
  131. % <size in points (72 per inch)> pt <size in user-units>
  132. % Feed pt through the default matrix to get device coordinates,
  133. % and then reverse transform it through the current matrix to get user units
  134. /pt { dup matrix defaultmatrix dtransform idtransform pop abs } def
  135.  
  136. % Macro to define fonts-takes "/ID Size /Font-Name" as params
  137. /DF { findfont exch pt dup 0.8 mul /STRH exch def scalefont def } def
  138. % Define a default text font...
  139. /DT { /DT0 20 /Times-Roman DF DT0 SF } def
  140. % Macros for positioning Text-take "(string) x y" as params
  141. /strbox { gsave newpath 0 0 moveto false charpath
  142.           40 setflat flattenpath pathbbox grestore } def
  143. %/strsizes { strbox 4 2 roll exch pop } def
  144. /strsizes { stringwidth pop STRH 0 } def
  145. % Usage: string    _strsizes_     width height depth
  146. /TOP { pop -1 mul } def
  147. /VCENT { pop -.5 mul } def
  148. /LOW { pop pop 0 } def
  149. /BOT { exch pop -1 mul } def
  150. /LEFT { exch pop 0 exch } def
  151. /HCENT { exch -.5 mul exch } def
  152. /RIGHT { exch -1 mul exch } def
  153.  
  154. /DEBUG { (Now showing:) print dup print (\n) print } def
  155. /TUL { moveto dup strsizes TOP LEFT rmoveto show } def
  156. /TUC { moveto dup strsizes TOP HCENT rmoveto show } def
  157. /TUR { moveto dup strsizes TOP RIGHT rmoveto show } def
  158. /TCL { moveto dup strsizes VCENT LEFT rmoveto show } def
  159. /TCC { moveto dup strsizes VCENT HCENT rmoveto show } def
  160. /TCR { moveto dup strsizes VCENT RIGHT rmoveto show } def
  161. /TLL { moveto dup strsizes LOW LEFT rmoveto show } def
  162. /TLC { moveto dup strsizes LOW HCENT rmoveto show } def
  163. /TLR { moveto dup strsizes LOW RIGHT rmoveto show } def
  164. /TBL { moveto dup strsizes BOT LEFT rmoveto show } def
  165. /TBC { moveto dup strsizes BOT HCENT rmoveto show } def
  166. /TBR { moveto dup strsizes BOT RIGHT rmoveto show } def
  167. % Shorthand for things
  168. /LD { load def } def
  169. /S /show LD
  170. /M /moveto LD
  171. /L /lineto LD
  172. /R /rlineto LD
  173. /DS { /DOTSIZE exch def } def
  174. 5 pt DS
  175. /DOT { DOTSIZE 0 360 arc } def
  176. /D { 2 copy lineto stroke moveto } def
  177. /CT /rcurveto LD
  178. /CI { 0 360 arc } def
  179. /CP /closepath LD
  180. /NP /newpath LD
  181. /SF /setfont LD
  182. % defaults to use the old til-type stuff.  (FillPath and StrokePath)
  183. /FP { finpath } def
  184. /SP { finpath } def
  185. % Shorthand for colors
  186. /FILL { /FP /fill LD /SP /FP LD } def
  187. /FILLOUT { /FP { gsave gsave fill grestore 0 setgray stroke grestore } def 
  188.            /SP /FP LD } def
  189. /FILLSTROKE { /FP /fill LD /SP /stroke LD } def
  190. /STROKE { /FP /stroke LD /SP /FP LD } def
  191. /SG /setgray LD
  192. /SLW /setlinewidth LD
  193. /SLJ /setlinejoin LD
  194. /SLC /setlinecap LD
  195. /SD /setdash LD
  196. % Stuff to include comments in files
  197. /CmtY 10 def   % Starting Y position
  198. /Cmt { 20 CmtY moveto /Helvetica findfont 8 scalefont setfont show 
  199.        /CmtY CmtY 10 add store } def
  200.